Skip to content

767_count_domens#788

Open
vovanbravin wants to merge 3 commits intodevfrom
767_count_domens
Open

767_count_domens#788
vovanbravin wants to merge 3 commits intodevfrom
767_count_domens

Conversation

@vovanbravin
Copy link
Collaborator

No description provided.

@vovanbravin
Copy link
Collaborator Author

Запрещенные домены не добавлял проверку, так как есть уже критерий banned_words_in_lit, который уже проверяет это момент (тестировал).

Copy link
Collaborator

@HadronCollider HadronCollider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправьте логику в #776 и подтяните изменения
После поставьте лейбл "need_review"

@github-actions github-actions bot added the has conflicts if new merge has conflicts label Mar 13, 2026
@vovanbravin vovanbravin added need_review and removed has conflicts if new merge has conflicts labels Mar 13, 2026
@HadronCollider HadronCollider changed the base branch from 762_duplicate_literature_references to dev March 16, 2026 18:04
return start_index

def find_domains(self, sources: str):
pattern = r'(?:https?|ftp)?://([^/\s?#]+)'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вынесите в поле класса

Comment on lines +185 to +188
if match and match.group(1):
self.literature_domains.append(match.group(1))
else:
self.literature_domains.append('') #чтобы можно было определить номер
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сократите до 1 строки (тернарный оператор)

break
return start_index

def find_domains(self, sources: str):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

смысла в этой функции как методе класса - 0 (он ещё и меняет состояние объекта, хотя вроде как должен просто найти домены) - проще regexp использовать в count_sources_*, и self.literature_domains.append делать там же (там будет и доступ к индексу)

if match and match.group(1):
self.literature_domains.append(match.group(1))
else:
self.literature_domains.append('') #чтобы можно было определить номер
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Чтобы определить номер, достаточно хранить его - вместе с доменом, иначе у вас есть список из 100 пустых строк (=много источников), потому что доменов среди нет нет

counter = Counter([text.lower() for text in self.literature_reference_text])
def checking_duplicate_sources(self, sources: list[str], max_count: int) -> list:
"""Функция нахождения дубликатов в определенных позициях"""
counter = Counter([text.lower() for text in sources])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

замените лист на генератор - он будет работать быстрее и меньше займет памяти

Comment on lines 160 to +161
for text, count in counter.items():
if count >= 2:
positions_duplicates = [i + 1 for i, text_in_ref in enumerate(self.literature_reference_text) if text == text_in_ref.lower()]
if count >= max_count and text != '':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Чтобы не делать на каждом шаге итерации сравнение text != '' - можно ещё на этапе формирования Counter не добавлять эти строки (например, фильтруя text.lower() for text in sources if text.strip())

def checking_duplicate_sources(self) -> list:
"""Функция нахождения дубликатов в источниках"""
counter = Counter([text.lower() for text in self.literature_reference_text])
def checking_duplicate_sources(self, sources: list[str], max_count: int) -> list:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

добавьте для max_count значение по умолчанию (= исходная логика с дубликатами источников)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants